/**
 * @param {number[]} nums
 * @return {number[][]}
 */
 var permuteUnique = function(nums) {
    let res = [], path = [], used = []
    const backTracking = function(){
      if(path.length === nums.length){
        res.push([...path])
        return
      }
      for(let i = 0;i < nums.length;i++){
        if(i > 0 && nums[i] === nums[i] && !nums[i]){
          // nums[i]为false 表示这个在这一层被用过
          continue
        }
        used[i] = true
        path.push(nums[i])
        backTracking()
        path.pop()
        used[i] = false
      }
    }
    backTracking()
    return res
};